//
//  MapTableViewCell.m
//  YiBaoStore
//
//  Created by 吕清毅 on 2018/12/1.
//  Copyright © 2018年 小河. All rights reserved.
//

#import "MapTableViewCell.h"

@implementation MapTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setMainView];
    }
    return self;
}

- (void)setMainView
{
    if (!self.logoIV) {
        self.logoIV = [UIImageView new];
        self.logoIV.image = [UIImage imageNamed:@"mapAddUn"];
        [self addSubview:self.logoIV];
    }
    if (!self.titleLab) {
        self.titleLab = [UILabel new];
        self.titleLab.textColor = UIColorFromHex(0x333333);
        self.titleLab.font = FontMediumWithSize(14);
        [self addSubview:self.titleLab];
    }
    if (!self.desLab) {
        self.desLab = [UILabel new];
        self.desLab.textColor = UIColorFromHex(0x999999);
        self.desLab.font = FontWithSize(12);
        [self addSubview:self.desLab];
    }
    if (!self.lineView) {
        self.lineView = [UIView new];
        self.lineView.backgroundColor = UIColorFromHex(0xE3E3E3);
        [self addSubview:self.lineView];
    }
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.logoIV.frame = CGRectMake(25, 17, 16, 16);
    self.titleLab.frame = CGRectMake(51, 10, self.width-61, 14);
    self.desLab.frame = CGRectMake(self.titleLab.left, self.titleLab.bottom+5, self.titleLab.width, 12);
    self.lineView.frame = CGRectMake(20, self.height-1, self.width-20, 1);
}

- (void)getModel:(AMapPOI *)model
{
    if (self.indexPath.row == 0)
    {
        self.logoIV.image = [UIImage imageNamed:@"mapYellow"];
        self.logoIV.frame = CGRectMake(25, 17, 12, 14);
        self.titleLab.textColor = goldColor;
    }
    self.titleLab.text = model.name;
    self.desLab.text = model.address;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
